/**
 * Description:
 *
 * @author      Eden
 * @datetime    2016/12/4 22:26
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

(function () {

    "use strict";

    var api = {
        deleteBaseUrl: '/farm/base/del'
    };

    sm.controller('base-farm-index', ['$scope', '$http', 'Modal', function ($scope, $http, Modal) {

        $scope.deleteBase = function (baseId) {
            Modal.alert({
                title: "操作提示",
                content: "您确定要删除该供应商吗？",
                buttons:[{
                    name: "取消"
                }, {
                    name: "确定删除",
                    event: function () {
                        doDelete(baseId);
                    }
                }]
            });
        };

        function doDelete(baseID) {
            $http.post(api.deleteBaseUrl, {
                id: baseID
            }).success(function (res) {
                if (res.state) {
                    location.href = '/farm/base/index';
                } else {
                    Modal.error(res.error ? res.error : '删除失败');
                }
            });
        }

    }]);

})();